#include "stdafx.h"
#include "ASN1BitString.h"


typedef std::pair<std::string, std::vector<byte>> bitstringEncodingParam;

class ASN1BitStringEncodingTestCase : public ::testing::TestWithParam<bitstringEncodingParam>
{
};

TEST_P(ASN1BitStringEncodingTestCase, Encode)
{
	AppliedCryptography::ASN1BitString val(GetParam().first);
	std::vector<byte> ret;

	ret = val.encode();

	// Output size should be as expected
	ASSERT_EQ(GetParam().second.size(), ret.size()) << "Value: " << GetParam().first;

	for(unsigned int i = 0; i < GetParam().second.size(); ++i)
	{
		EXPECT_NO_THROW(EXPECT_EQ((int)GetParam().second.at(i), (int)ret.at(i)) 
			<< "Index i: " << i << "\n"
			<< "Value: " << GetParam().first);
	};
};

std::string str1("JANIS");
byte bytesStr1[] = {0x03, 0x06, 0x00, 0x4A, 0x41, 0x4E, 0x49, 0x53};
std::vector<byte> vectStr1(bytesStr1, bytesStr1 + sizeof(bytesStr1) / sizeof(byte));

INSTANTIATE_TEST_CASE_P(ASN1BitStringEncodingTest,
                        ASN1BitStringEncodingTestCase,
						::testing::Values( 
							bitstringEncodingParam(str1, vectStr1) )
						);

